/********************************************************************************
TITLE:                      	Using Virtual Functions
FILENAME:                   	audiocd.cpp
PREPARED FOR:               	CS215 Section CS13-02
PROGRAMMER(S):              	Eric (Fox) Crowell, Timothy Drye
DEVELOPMENT DATE:           	< 12/15/13 >
COMPILER USED:      			Microsoft Visual Studio Professional 2013
- Version 12.0.21005.1 REL
TARGET PLATFORM:         	    Windows 8 x64
================================================================================
REVISION HISTORY

DATE         PROGRAMMER          DESCRIPTION OF CHANGES MADE
------------------------------------------------------------------------------
<12/18/13       Fox                 Class Created.                           >
*******************************************************************************/

#include "audiocd.h"

// For the default constructor, call the parent's and set. [Fox]
AudioCD::AudioCD():Media() {
	cout << "      --- Number of Tracks: ";
	cin >> NumberOfTracks; // Int
	if (NumberOfTracks < 1){ NumberOfTracks = 1; }
	cout << "      [i] Your \"Audio CD\" media item has been created.\n";
	cout << "      --------------------------------------------------\n\n";
}

// Overloaded constructor. [Fox]
AudioCD::AudioCD(const string  & InTitle, const string & InArtist, const string & InWherePurchased,
float InCost, Time  & InRunningTime, int InNumberOfTracks)
:Media(InTitle, InArtist, InWherePurchased, InCost, InRunningTime) {
	NumberOfTracks = InNumberOfTracks;
}

// Returns the boolean data member IsCD_AtBeginning. [Fox]
bool AudioCD::IsCD_AtBeginning() {
	return(CD_AtBeginning);
}

// Returns the boolean data member IsCD_AtEnd. [Fox]
bool AudioCD::IsCD_AtEnd(){
	return(CD_AtEnd);
}

// Returns the boolean data member NumberOfTracks. [Fox]
int AudioCD::GetNumberOfTracks(){
	return(NumberOfTracks);
}

// Returns the boolean data member CurrentTrack. [Fox]
int AudioCD::GetCurrentTrack(){
	return(CurrentTrack);
}

// Play the media (Progresses the end of the media). [Fox]
void AudioCD::Play(){
	if (IsCD_AtEnd() || CurrentTrack > NumberOfTracks){
		cout << "\n      [!] This media has reached the end of its playlist. Please rewind the media before playing.\n\n";
		CD_AtBeginning = false;
		CD_AtEnd = true;
	}
	else{
		cout << "\n      [i] Media has just played track #" << CurrentTrack << ".\n";
		CurrentTrack++;
		if (CurrentTrack <= NumberOfTracks){
			cout << "      [i] Next track is #" << CurrentTrack << ".\n\n";
		}
		else {
			cout << "      [i] That was the last track in the playlist.\n\n";
		}
		CD_AtBeginning = false;
		CD_AtEnd = false;
	}
}

// Fast forward to the end of the media. [Fox]
 void AudioCD::FastForward(){
	 if (IsCD_AtEnd()){
		 cout << "\n      [!] This media is already at the end.\n\n";
	 } else {
		 cout << "\n      [i] Media has been fast forwarded to the end.\n\n";
		 CD_AtBeginning = false;
		 CD_AtEnd = true;
	 }
}
 
// Rewind to the begining of the media. [Fox]
 void AudioCD::Rewind(){
	 if (IsCD_AtBeginning()){
		 cout << "\n      [!] This media is already at the beginning.\n\n";
	 }
	 else {
		 cout << "\n      [i] Media has been rewound to the beginning.\n\n";
		 CD_AtBeginning = true;
		 CD_AtEnd = false;
	 }
}

// Prints out the information about the media. [Fox]
void AudioCD::PrintMedia(ostream & Out){
	Media::PrintMedia(Out); // Call the parent's PrintMedia to output its data members.
	Out << "      --- Number of Tracks: " << NumberOfTracks << "\n";
	Out << "      --- Media Type: Audio CD\n";
	Out << "      --------------------------------------------------\n\n";
}